﻿using System;
using System.Collections.Generic;
using KKSG;
using UILib;
using UnityEngine;
using XMainClient.UI;
using XUtliPoolLib;

namespace XMainClient
{
	// Token: 0x02000D9C RID: 3484
	internal class XLevelDoodadMgr : XSingleton<XLevelDoodadMgr>
	{
		// Token: 0x0600BD5D RID: 48477 RVA: 0x00273E14 File Offset: 0x00272014
		public XLevelDoodadMgr()
		{
			this._showRollOverNoticeCb = new XTimerMgr.ElapsedEventHandler(this.ShowRollOverNotice);
			this._delayGenerateDoodadCb = new XTimerMgr.ElapsedEventHandler(this.DelayGenerateDoodad);
		}

		// Token: 0x0600BD5E RID: 48478 RVA: 0x00273E9C File Offset: 0x0027209C
		public override bool Init()
		{
			this._HpbarRoot = XSingleton<XGameUI>.singleton.HpbarRoot.gameObject;
			this._DoodadPickCD = (float)XSingleton<XGlobalConfig>.singleton.GetInt("DoodadPickCD") / 100f;
			return true;
		}

		// Token: 0x0600BD5F RID: 48479 RVA: 0x00273EE0 File Offset: 0x002720E0
		public override void Uninit()
		{
			this._doodads.Clear();
			this._DropedDoodads.Clear();
			this._NoticeDictionary.Clear();
			this._HpbarRoot = null;
		}

		// Token: 0x0600BD60 RID: 48480 RVA: 0x00273F10 File Offset: 0x00272110
		public void CacheDoodad(List<DoodadInfo> doodads)
		{
			//bool flag = this._doodads.Count > 0;
			if (this._doodads.Count > 0)
			{
				this.OnClearDoodad();
			}
			this._doodads.Clear();
			for (int i = 0; i < doodads.Count; i++)
			{
				DoodadInfo doodadInfo = doodads[i];
				XLevelDoodad xlevelDoodad = new XLevelDoodad();
				xlevelDoodad.index = (uint)i;
				xlevelDoodad.wave = doodadInfo.waveid;
				xlevelDoodad.type = (XDoodadType)doodadInfo.type;
				xlevelDoodad.id = doodadInfo.id;
				xlevelDoodad.count = doodadInfo.count;
				xlevelDoodad.dropped = false;
				xlevelDoodad.picked = false;
				xlevelDoodad.lastPickTime = 0f;
				this._doodads.Add(xlevelDoodad);
			}
		}

		// Token: 0x0600BD61 RID: 48481 RVA: 0x00273FC8 File Offset: 0x002721C8
		public void OnMonsterDie(XEntity entity)
		{
			XLevelDoodad xlevelDoodad = this.FindWave(entity.Wave);
			if (xlevelDoodad != null)
			{
				if (!xlevelDoodad.dropped)
				{
					XLevelDynamicInfo waveDynamicInfo = XSingleton<XLevelSpawnMgr>.singleton.CurrentSpawner.GetWaveDynamicInfo(entity.Wave);
					int num = waveDynamicInfo._TotalCount - waveDynamicInfo._dieCount;
					float num2 = 1f / (float)(num + 1);
					float num3 = XSingleton<XCommon>.singleton.RandomFloat(0f, 1f);
					if (num3 <= num2)
					{
						xlevelDoodad.dropped = true;
						xlevelDoodad.pos = entity.EngineObject.Position;
						xlevelDoodad.templateid = entity.Attributes.TypeID;
						if (entity.IsBoss && xlevelDoodad.id == 1U)
						{
							this._doodads.Remove(xlevelDoodad);
						}
						this.DelayGenerateClientDoodad(xlevelDoodad);
					}
				}
			}
		}

		// Token: 0x0600BD62 RID: 48482 RVA: 0x002740B4 File Offset: 0x002722B4
		public void ReportServerList(List<uint> l)
		{
			l.Clear();
			for (int i = 0; i < this._doodads.Count; i++)
			{
				if (this._doodads[i].picked)
				{
					l.Add((uint)this._doodads[i].wave);
				}
			}
		}

		// Token: 0x0600BD63 RID: 48483 RVA: 0x00274114 File Offset: 0x00272314
		public void OnLeaveScene()
		{
			for (int i = 0; i < this._doodads.Count; i++)
			{
				if (this._doodads[i].dropped && !this._doodads[i].picked)
				{
					if (this._doodads[i].doodad != null)
					{
						XResourceLoaderMgr.SafeDestroy(ref this._doodads[i].doodad, true);
					}
					if (this._doodads[i].billboard != null)
					{
						XResourceLoaderMgr.SafeDestroy(ref this._doodads[i].billboard, true);
					}
				}
			}
			this._doodads.Clear();
			this._NoticeDictionary.Clear();
		}

		// Token: 0x0600BD64 RID: 48484 RVA: 0x002741F8 File Offset: 0x002723F8
		public void OnClearDoodad()
		{
			for (int i = 0; i < this._TimerToken.Count; i++)
			{
				XSingleton<XTimerMgr>.singleton.KillTimer(this._TimerToken[i]);
			}
			this._TimerToken.Clear();
			for (int j = 0; j < this._doodads.Count; j++)
			{
				if (this._doodads[j].dropped && !this._doodads[j].picked)
				{
					if (this._doodads[j].doodad != null)
					{
						XResourceLoaderMgr.SafeDestroy(ref this._doodads[j].doodad, true);
					}
					if (this._doodads[j].billboard != null)
					{
						XResourceLoaderMgr.SafeDestroy(ref this._doodads[j].billboard, true);
					}
				}
			}
			this._doodads.Clear();
		}

		// Token: 0x0600BD65 RID: 48485 RVA: 0x00274314 File Offset: 0x00272514
		protected XLevelDoodad FindWave(int wave)
		{
			for (int i = 0; i < this._doodads.Count; i++)
			{
				if (this._doodads[i].wave == wave)
				{
					return this._doodads[i];
				}
			}
			return null;
		}

		// Token: 0x0600BD66 RID: 48486 RVA: 0x0027436C File Offset: 0x0027256C
		protected XLevelDoodad FindWaveByIndex(uint index)
		{
			for (int i = 0; i < this._doodads.Count; i++)
			{
				if (this._doodads[i].index == index)
				{
					return this._doodads[i];
				}
			}
			return null;
		}

		// Token: 0x0600BD67 RID: 48487 RVA: 0x002743C4 File Offset: 0x002725C4
		private bool GenerateDoodadFx(XLevelDoodad doo, Vector3 pos)
		{
			XEntityStatistics.RowData byID = XSingleton<XEntityMgr>.singleton.EntityStatistics.GetByID(doo.templateid);
			if (byID != null && byID.Type == 1)
			{
				XEntityPresentation.RowData byPresentID = XSingleton<XEntityMgr>.singleton.EntityInfo.GetByPresentID(byID.PresentID);
				Vector3 vector = XSingleton<XScene>.singleton.GameCamera.UnityCamera.transform.position - pos;
				vector.y = 0f;
				vector.Normalize();
				float num = float.Parse(XSingleton<XGlobalConfig>.singleton.GetValue("DoodadDist"));
				if (byPresentID != null)
				{
					doo.pos += vector * (num + byPresentID.BoundRadius);
					pos += vector * (num + byPresentID.BoundRadius);
				}
				else
				{
					doo.pos += vector * num;
					pos += vector * num;
				}
			}
			ItemList.RowData itemConf = XBagDocument.GetItemConf((int)doo.id);
			if (itemConf != null)
			{
				string doodadFx = itemConf.DoodadFx;
				string[] array = doodadFx.Split(XGlobalConfig.ListSeparator);
				if (array.Length > 1)
				{
					int num2 = int.Parse(array[0]);
					if (num2 == 0)
					{
						XFx xfx = XSingleton<XFxMgr>.singleton.CreateFx(array[2], null, true);
						xfx.Play(pos, Quaternion.identity, Vector3.one, 1f);
						if (doo.id == 1U)
						{
							XSingleton<XAudioMgr>.singleton.PlaySoundAt(pos, "Audio/common/Coins");
						}
						if (!XSingleton<XGame>.singleton.SyncMode && !XSingleton<XLevelFinishMgr>.singleton.IsCurrentLevelFinished)
						{
							uint num3;
							if ((float)array.Length >= 3f)
							{
								num3 = XSingleton<XTimerMgr>.singleton.SetTimer(float.Parse(array[3]), this._delayGenerateDoodadCb, doo);
							}
							else
							{
								num3 = XSingleton<XTimerMgr>.singleton.SetTimer(1.5f, this._delayGenerateDoodadCb, doo);
							}
							doo.token = num3;
							this._TimerToken.Add(num3);
						}
						return true;
					}
					XSingleton<XAudioMgr>.singleton.PlaySoundAt(pos, "Audio/common/Item_Gem");
					return false;
				}
			}
			return false;
		}

		// Token: 0x0600BD68 RID: 48488 RVA: 0x00274628 File Offset: 0x00272828
		private bool GetDoodadInfo(XLevelDoodad doo, ref string location, ref string name, ref Vector3 offset, ref int quality, ref bool isequip)
		{
			bool result;
			if (doo == null)
			{
				XSingleton<XDebug>.singleton.AddErrorLog("Doo is null!", null, null, null, null, null);
				result = false;
			}
			else
			{
				if (doo.type == XDoodadType.Item)
				{
					FashionList.RowData fashionConf = XBagDocument.GetFashionConf((int)doo.id);
					if (fashionConf != null)
					{
						string text = "";
						string equipPrefabModel = XEquipDocument.GetEquipPrefabModel(fashionConf, XSingleton<XEntityMgr>.singleton.Player.BasicTypeID, out text);
						if (equipPrefabModel != "")
						{
							location = "Equipments/" + equipPrefabModel;
							offset = this.GetDoodadOffset(XSingleton<XEntityMgr>.singleton.Player.BasicTypeID, (FashionPosition)fashionConf.EquipPos);
							ItemList.RowData itemConf = XBagDocument.GetItemConf((int)doo.id);
							if (itemConf == null)
							{
								XSingleton<XDebug>.singleton.AddErrorLog("ItemID not exist:" + doo.id, null, null, null, null, null);
								return false;
							}
							name = XSingleton<UiUtility>.singleton.ChooseProfString(itemConf.ItemName, 0U);
							quality = (int)itemConf.ItemQuality;
						}
					}
					else
					{
						EquipList.RowData equipConf = XBagDocument.GetEquipConf((int)doo.id);
						if (equipConf != null)
						{
							string text2;
							if (equipConf.EquipPos == 0)
							{
								text2 = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadPrefabHead");
							}
							else
							{
								if (equipConf.EquipPos == 7)
								{
									text2 = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadPrefabNecklace");
								}
								else
								{
									if (equipConf.EquipPos == 8)
									{
										text2 = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadPrefabEarring");
									}
									else
									{
										if (equipConf.EquipPos == 9)
										{
											text2 = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadPrefabRing");
										}
										else
										{
											string text3 = "";
											text2 = XEquipDocument.GetDefaultEquipModel(XSingleton<XEntityMgr>.singleton.Player.BasicTypeID, (FashionPosition)equipConf.EquipPos, out text3);
										}
									}
								}
							}
							if (text2 != "")
							{
								location = "Equipments/" + text2;
								offset = this.GetDoodadOffsetEquip(XSingleton<XEntityMgr>.singleton.Player.BasicTypeID, (EquipPosition)equipConf.EquipPos);
								ItemList.RowData itemConf2 = XBagDocument.GetItemConf((int)doo.id);
								if (itemConf2 == null)
								{
									XSingleton<XDebug>.singleton.AddErrorLog("ItemID not exist:" + doo.id, null, null, null, null, null);
									return false;
								}
								name = XSingleton<UiUtility>.singleton.ChooseProfString(itemConf2.ItemName, 0U);
								quality = (int)itemConf2.ItemQuality;
								isequip = true;
							}
						}
						else
						{
							ItemList.RowData itemConf3 = XBagDocument.GetItemConf((int)doo.id);
							if (itemConf3 == null)
							{
								XSingleton<XDebug>.singleton.AddErrorLog("ItemID not exist:" + doo.id, null, null, null, null, null);
								return false;
							}
							string[] array = itemConf3.DoodadFx.Split(XGlobalConfig.ListSeparator);
							if (array.Length < 3)
							{
								location = ((array.Length > 1) ? array[1] : array[0]);
								name = XSingleton<UiUtility>.singleton.ChooseProfString(itemConf3.ItemName, 0U);
								quality = (int)itemConf3.ItemQuality;
							}
						}
					}
				}
				else
				{
					if (doo.type == XDoodadType.Buff || doo.type == XDoodadType.BuffHorse || doo.type == XDoodadType.BuffSkill || doo.type == XDoodadType.BigMeleeItem)
					{
						BuffTable.RowData buffData = XSingleton<XBuffTemplateManager>.singleton.GetBuffData((int)doo.id, 1);
						if (buffData == null)
						{
							XSingleton<XDebug>.singleton.AddErrorLog("BuffID not exist:" + doo.id, null, null, null, null, null);
							return false;
						}
						location = buffData.BuffDoodadFx;
						name = buffData.BuffName;
						quality = -1;
					}
				}
				result = true;
			}
			return result;
		}

		// Token: 0x0600BD69 RID: 48489 RVA: 0x00274A24 File Offset: 0x00272C24
		private GameObject GenerateDoodadGO(XLevelDoodad doo, Vector3 pos, string location, bool isequip, int quality, Vector3 offset)
		{
			GameObject result;
			if (doo == null)
			{
				XSingleton<XDebug>.singleton.AddErrorLog("Doo is null!", null, null, null, null, null);
				result = null;
			}
			else
			{
				GameObject gameObject = null;
				if (doo.type == XDoodadType.Buff || doo.type == XDoodadType.BuffHorse || doo.type == XDoodadType.BuffSkill || doo.type == XDoodadType.BigMeleeItem)
				{
					gameObject = (XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab(location, true, false) as GameObject);
				}
				else
				{
					GameObject gameObject2 = XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab(location, true, false) as GameObject;
					if (gameObject2 == null)
					{
						XSingleton<XDebug>.singleton.AddErrorLog("Equip == null", null, null, null, null, null);
						return null;
					}
					if (isequip)
					{
						string str;
						switch (quality)
						{
						case 3:
							str = "Szcs_glow";
							break;
						case 4:
							str = "Szbz_glow";
							break;
						case 5:
							str = "Szbh_glow";
							break;
						default:
							str = "Szty_glow";
							break;
						}
						gameObject = (XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab("Prefabs/Effects/Default/" + str, true, false) as GameObject);
						if (gameObject == null)
						{
							return null;
						}
						Transform transform = XSingleton<XCommon>.singleton.FindChildRecursively(gameObject.transform, "zhuangbei");
						if (gameObject2.transform == null || transform == null)
						{
							XSingleton<XDebug>.singleton.AddErrorLog("Equip or t = null", null, null, null, null, null);
							return null;
						}
						XSingleton<UiUtility>.singleton.AddChild(transform, gameObject2.transform);
						gameObject2.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
						gameObject2.transform.localPosition += offset;
					}
					else
					{
						ItemList.RowData itemConf = XBagDocument.GetItemConf((int)doo.id);
						if (itemConf == null)
						{
							XSingleton<XDebug>.singleton.AddErrorLog("Doo.Id not exists : " + (int)doo.id, null, null, null, null, null);
							return null;
						}
						string[] array = itemConf.DoodadFx.Split(XGlobalConfig.ListSeparator);
						if (array.Length > 1)
						{
							int num = int.Parse(array[0]);
							if (num == 0)
							{
								gameObject = gameObject2;
								gameObject2.transform.localPosition = pos;
							}
							else
							{
								if (num == 1)
								{
									gameObject = (XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab(array[2], true, false) as GameObject);
									if (gameObject == null)
									{
										return null;
									}
									Transform transform2 = XSingleton<XCommon>.singleton.FindChildRecursively(gameObject.transform, "Point_drop01");
									gameObject2.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
									if (gameObject2.transform == null || transform2 == null)
									{
										XSingleton<XDebug>.singleton.AddErrorLog("Equip or t = null", null, null, null, null, null);
										return null;
									}
									XSingleton<UiUtility>.singleton.AddChild(transform2, gameObject2.transform);
								}
							}
						}
						else
						{
							gameObject = gameObject2;
							gameObject2.transform.localPosition = pos;
						}
					}
				}
				if (gameObject == null)
				{
					XSingleton<XDebug>.singleton.AddErrorLog("Go = null!", null, null, null, null, null);
					result = null;
				}
				else
				{
					float num2 = XSingleton<XScene>.singleton.TerrainY(pos);
					gameObject.transform.position = new Vector3(pos.x, num2 + 0.5f, pos.z);
					result = gameObject;
				}
			}
			return result;
		}

		// Token: 0x0600BD6A RID: 48490 RVA: 0x00274DDC File Offset: 0x00272FDC
		private bool AttachDoodadBillboard(XLevelDoodad doo, string name, int quality)
		{
			bool result;
			if (doo == null)
			{
				result = false;
			}
			else
			{
				GameObject gameObject = XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab("UI/Billboard/DoodadBillboard", true, false) as GameObject;
				if (gameObject == null)
				{
					XSingleton<XDebug>.singleton.AddErrorLog("Billboard create failed", null, null, null, null, null);
					result = false;
				}
				else
				{
					XSingleton<UiUtility>.singleton.AddChild(this._HpbarRoot, gameObject);
					gameObject.transform.localScale = new Vector3(0.005f, 0.005f, 0.005f);
					doo.billboard = gameObject;
					IXUILabel ixuilabel = gameObject.transform.Find("Name").GetComponent("XUILabel") as IXUILabel;
					IXUILabelSymbol ixuilabelSymbol = gameObject.transform.Find("Name").GetComponent("XUILabelSymbol") as IXUILabelSymbol;
					if (ixuilabel != null)
					{
						SceneType sceneType = XSingleton<XScene>.singleton.SceneType;
						if (sceneType != SceneType.SCENE_HORSE_RACE && sceneType != SceneType.SCENE_WEEKEND4V4_HORSERACING)
						{
							if (doo.count > 1U)
							{
								ixuilabelSymbol.InputText = name + doo.count.ToString();
							}
							else
							{
								ixuilabelSymbol.InputText = name;
							}
							ixuilabel.SetColor(XSingleton<UiUtility>.singleton.GetItemQualityColor(quality));
						}
						else
						{
							ixuilabel.SetText(XStringDefineProxy.GetString("RACE_DOODAD_NAME"));
						}
					}
					if (XSingleton<XScene>.singleton.SceneType == SceneType.SCENE_BATTLEFIELD_FIGHT)
					{
						ulong roleid = doo.roleid;
						string text = null;//zcg  XBattleFieldBattleDocument.Doc.userIdToRole[roleid];
						if (text != null)
						{
							ixuilabelSymbol.InputText = text + "\n" + ixuilabel.GetText();
						}
					}
					result = true;
				}
			}
			return result;
		}

		// Token: 0x0600BD6B RID: 48491 RVA: 0x00274F94 File Offset: 0x00273194
		private GameObject GenerateDoodadObject(XLevelDoodad doo, Vector3 pos)
		{
			string text = "";
			string name = "";
			Vector3 zero = Vector3.zero;
			int quality = 0;
			bool isequip = false;
			GameObject result;
			if (!this.GetDoodadInfo(doo, ref text, ref name, ref zero, ref quality, ref isequip))
			{
				XSingleton<XDebug>.singleton.AddErrorLog("doodad info get error", null, null, null, null, null);
				result = null;
			}
			else
			{
				if (text == "")
				{
					result = null;
				}
				else
				{
					GameObject gameObject = this.GenerateDoodadGO(doo, pos, text, isequip, quality, zero);
					if (gameObject == null)
					{
						XSingleton<XDebug>.singleton.AddErrorLog("Doodad gameobject create failed", null, null, null, null, null);
						result = null;
					}
					else
					{
						doo.doodad = gameObject;
						doo.pos = pos;
						if (!this.AttachDoodadBillboard(doo, name, quality))
						{
							XSingleton<XDebug>.singleton.AddErrorLog("Doodad billboard create failed", null, null, null, null, null);
							result = null;
						}
						else
						{
							XDoodadCreateArgs @event = XEventPool<XDoodadCreateArgs>.GetEvent();
							@event.doo = doo;
							@event.Firer = XSingleton<XGame>.singleton.Doc;
							XSingleton<XEventMgr>.singleton.FireEvent(@event);
							result = gameObject;
						}
					}
				}
			}
			return result;
		}

		// Token: 0x0600BD6C RID: 48492 RVA: 0x002750B4 File Offset: 0x002732B4
		private void DelayGenerateClientDoodad(object obj)
		{
			XLevelDoodad xlevelDoodad = (XLevelDoodad)obj;
			this.GenerateDoodad(xlevelDoodad, xlevelDoodad.pos);
		}

		// Token: 0x0600BD6D RID: 48493 RVA: 0x002750D8 File Offset: 0x002732D8
		protected GameObject GenerateDoodad(XLevelDoodad doo, Vector3 pos)
		{
			GameObject result;
			if (this.GenerateDoodadFx(doo, pos))
			{
				result = doo.doodad;
			}
			else
			{
				result = this.GenerateDoodadObject(doo, pos);
			}
			return result;
		}

		// Token: 0x0600BD6E RID: 48494 RVA: 0x0027510C File Offset: 0x0027330C
		protected Vector3 GetDoodadOffset(uint typeid, FashionPosition pos)
		{
			string value;
			switch (pos)
			{
			case FashionPosition.FASHION_START:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetHead");
				break;
			case FashionPosition.FashionUpperBody:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetUpperBody");
				break;
			case FashionPosition.FashionLowerBody:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetLowerBody");
				break;
			case FashionPosition.FashionGloves:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetGloves");
				break;
			case FashionPosition.FashionBoots:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetBoots");
				break;
			case FashionPosition.FashionMainWeapon:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetMainWeapon");
				break;
			case FashionPosition.FashionSecondaryWeapon:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetSecWeapon");
				break;
			case FashionPosition.FashionWings:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetWing");
				break;
			case FashionPosition.FashionTail:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetTail");
				break;
			case FashionPosition.FashionDecal:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetDecal");
				break;
			default:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetNormal");
				break;
			}
			string[] array = value.Split(XGlobalConfig.AllSeparators);
			float num = float.Parse(array[(int)((typeid - 1U) * 2U)]);
			float num2 = float.Parse(array[(int)((typeid - 1U) * 2U + 1U)]);
			return new Vector3(num, num2, 0f);
		}

		// Token: 0x0600BD6F RID: 48495 RVA: 0x00275260 File Offset: 0x00273460
		protected Vector3 GetDoodadOffsetEquip(uint typeid, EquipPosition pos)
		{
			string value;
			switch (pos)
			{
			case EquipPosition.EQUIP_START:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetHead");
				break;
			case EquipPosition.Upperbody:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetUpperBody");
				break;
			case EquipPosition.Lowerbody:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetLowerBody");
				break;
			case EquipPosition.Gloves:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetGloves");
				break;
			case EquipPosition.Boots:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetBoots");
				break;
			case EquipPosition.Mainweapon:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetMainWeapon");
				break;
			case EquipPosition.Secondaryweapon:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetSecWeapon");
				break;
			case EquipPosition.Necklace:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetNormal");
				break;
			case EquipPosition.Earrings:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetNormal");
				break;
			case EquipPosition.Rings:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetNormal");
				break;
			default:
				value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetNormal");
				break;
			}
			string[] array = value.Split(XGlobalConfig.AllSeparators);
			float num = float.Parse(array[(int)((typeid - 1U) * 2U)]);
			float num2 = float.Parse(array[(int)((typeid - 1U) * 2U + 1U)]);
			return new Vector3(num, num2, 0f);
		}

		// Token: 0x0600BD70 RID: 48496 RVA: 0x002753B4 File Offset: 0x002735B4
		public void OnDoodadPicked(int wave, uint index)
		{
			if (!XSingleton<XGame>.singleton.SyncMode)
			{
				this.OnDoodadPickedSolo(wave, index);
			}
			else
			{
				this.OnDoodadPickedSync(wave, index);
			}
		}

		// Token: 0x0600BD71 RID: 48497 RVA: 0x002753EC File Offset: 0x002735EC
		protected void OnDoodadPickedSolo(int wave, uint index)
		{
			XLevelDoodad xlevelDoodad = this.FindWaveByIndex(index);
			if (xlevelDoodad == null)
			{
				XSingleton<XDebug>.singleton.AddLog("Pick up some doodad not exists??", null, null, null, null, null, XDebugColor.XDebug_None);
			}
			else
			{
				if (xlevelDoodad.type == XDoodadType.Buff)
				{
					XBuffAddEventArgs @event = XEventPool<XBuffAddEventArgs>.GetEvent();
					@event.xBuffDesc.BuffID = (int)xlevelDoodad.id;
					@event.xBuffDesc.BuffLevel = (int)xlevelDoodad.count;
					@event.Firer = XSingleton<XEntityMgr>.singleton.Player;
					@event.xBuffDesc.CasterID = XSingleton<XEntityMgr>.singleton.Player.ID;
					XSingleton<XEventMgr>.singleton.FireEvent(@event);
				}
				if (xlevelDoodad.type == XDoodadType.Item)
				{
					XHUDDoodadArgs event2 = XEventPool<XHUDDoodadArgs>.GetEvent();
					event2.itemid = (int)xlevelDoodad.id;
					event2.count = (int)xlevelDoodad.count;
					event2.Firer = XSingleton<XEntityMgr>.singleton.Player;
					XSingleton<XEventMgr>.singleton.FireEvent(event2);
				}
				this._OnDoodadPickedSucc(xlevelDoodad, XSingleton<XEntityMgr>.singleton.Player);
			}
		}

		// Token: 0x0600BD72 RID: 48498 RVA: 0x002754FC File Offset: 0x002736FC
		protected void _OnDoodadPickedSucc(XLevelDoodad doo, XEntity p)
		{
			if (doo.doodad != null)
			{
				XDoodadDeleteArgs @event = XEventPool<XDoodadDeleteArgs>.GetEvent();
				@event.doo = doo;
				@event.Firer = XSingleton<XGame>.singleton.Doc;
				XSingleton<XEventMgr>.singleton.FireEvent(@event);
				doo.picked = true;
				if (doo.type == XDoodadType.Item)
				{
					Transform transform = XSingleton<XCommon>.singleton.FindChildRecursively(doo.doodad.transform, "zhuangbei");
					if (transform != null && transform.childCount > 0)
					{
						GameObject gameObject = transform.GetChild(0).gameObject;
						XSingleton<XResourceLoaderMgr>.singleton.UnSafeDestroy(gameObject, true, false);
					}
				}
				XResourceLoaderMgr.SafeDestroy(ref doo.doodad, true);
				XResourceLoaderMgr.SafeDestroy(ref doo.billboard, true);
				if (p != null)
				{
					XSingleton<XFxMgr>.singleton.CreateAndPlay("Effects/FX_Particle/Roles/Lzg_Ty/Ty_buff_xishou", p.EngineObject, Vector3.zero, Vector3.one, 1f, true, 5f, true);
				}
			}
		}

		// Token: 0x0600BD73 RID: 48499 RVA: 0x00275604 File Offset: 0x00273804
		protected void OnDoodadPickedSync(int wave, uint index)
		{
			XLevelDoodad xlevelDoodad = this.FindWaveByIndex(index);
			if (xlevelDoodad != null)
			{
				if (Time.time - xlevelDoodad.lastPickTime >= this._DoodadPickCD)
				{
					xlevelDoodad.lastPickTime = Time.time;
					RpcC2G_FetchEnemyDoodadReq rpcC2G_FetchEnemyDoodadReq = new RpcC2G_FetchEnemyDoodadReq();
					rpcC2G_FetchEnemyDoodadReq.oArg.waveid = xlevelDoodad.wave;
					rpcC2G_FetchEnemyDoodadReq.oArg.pos = new Vec3();
					rpcC2G_FetchEnemyDoodadReq.oArg.pos.x = xlevelDoodad.pos.x;
					rpcC2G_FetchEnemyDoodadReq.oArg.pos.y = xlevelDoodad.pos.y;
					rpcC2G_FetchEnemyDoodadReq.oArg.pos.z = xlevelDoodad.pos.z;
					rpcC2G_FetchEnemyDoodadReq.oArg.id = xlevelDoodad.id;
					rpcC2G_FetchEnemyDoodadReq.oArg.type = (int)xlevelDoodad.type;
					rpcC2G_FetchEnemyDoodadReq.oArg.count = xlevelDoodad.count;
					rpcC2G_FetchEnemyDoodadReq.oArg.index = xlevelDoodad.index;
					XSingleton<XClientNetwork>.singleton.Send(rpcC2G_FetchEnemyDoodadReq);
				}
			}
		}

		// Token: 0x0600BD74 RID: 48500 RVA: 0x00275720 File Offset: 0x00273920
		public void OnDoodadPickedSyncSucc(uint index, int wave, Vector3 posid, XEntity p, uint maxroll, uint playerroll)
		{
			XLevelDoodad xlevelDoodad = this.FindWaveByIndex(index);
			if (xlevelDoodad != null)
			{
				this._OnDoodadPickedSucc(xlevelDoodad, p);
				if (xlevelDoodad.type == XDoodadType.Item)
				{
					this.ShowGetItemNotice(xlevelDoodad, p);
				}
			}
		}

		// Token: 0x0600BD75 RID: 48501 RVA: 0x00275764 File Offset: 0x00273964
		private void ShowGetItemNotice(XLevelDoodad doo, XEntity p)
		{
			if (doo.type == XDoodadType.Item)
			{
				XHUDDoodadArgs @event = XEventPool<XHUDDoodadArgs>.GetEvent();
				@event.itemid = (int)doo.id;
				@event.count = (int)doo.count;
				@event.Firer = p;
				XSingleton<XEventMgr>.singleton.FireEvent(@event);
			}
		}

		// Token: 0x0600BD76 RID: 48502 RVA: 0x002757B8 File Offset: 0x002739B8
		protected void ShowStartRollNotice(XLevelDoodad doo, XEntity p, uint maxroll, uint playerroll)
		{
			string @string = XStringDefineProxy.GetString("DOODAD_DEPENDING");
			ItemList.RowData itemConf = XBagDocument.GetItemConf((int)doo.id);
			string itemQualityRGB = XSingleton<UiUtility>.singleton.GetItemQualityRGB((int)itemConf.ItemQuality);
			string arg = string.Format("[{0}]{1}[-]", itemQualityRGB, XSingleton<UiUtility>.singleton.ChooseProfString(itemConf.ItemName, 0U));
			string text = string.Format(@string, arg);
			uint num = XSingleton<UiUtility>.singleton.ShowSystemNoticeTip(text);
			XSingleton<XTimerMgr>.singleton.SetTimer(1f, this._showRollOverNoticeCb, num);
			XSyncDoodadInfo xsyncDoodadInfo = new XSyncDoodadInfo();
			xsyncDoodadInfo.doo = doo;
			xsyncDoodadInfo.owner = p;
			xsyncDoodadInfo.maxroll = maxroll;
			xsyncDoodadInfo.playerroll = playerroll;
			this._NoticeDictionary.Add(num, xsyncDoodadInfo);
		}

		// Token: 0x0600BD77 RID: 48503 RVA: 0x00275878 File Offset: 0x00273A78
		protected void ShowRollOverNotice(object o)
		{
			uint num = (uint)o;
			XSyncDoodadInfo xsyncDoodadInfo = this._NoticeDictionary[num];
			ItemList.RowData itemConf = XBagDocument.GetItemConf((int)xsyncDoodadInfo.doo.id);
			string itemQualityRGB = XSingleton<UiUtility>.singleton.GetItemQualityRGB((int)itemConf.ItemQuality);
			string text = string.Format("[{0}]{1}[-]", itemQualityRGB, XSingleton<UiUtility>.singleton.ChooseProfString(itemConf.ItemName, 0U));
			if (xsyncDoodadInfo.maxroll == xsyncDoodadInfo.playerroll)
			{
				string @string = XStringDefineProxy.GetString("DOODAD_RESULT_PLAYER");
				string text2 = string.Format(@string, text, xsyncDoodadInfo.maxroll);
				XSingleton<UiUtility>.singleton.EditSystemNoticeTip(text2, num);
			}
			else
			{
				string string2 = XStringDefineProxy.GetString("DOODAD_RESULT");
				string text3 = string.Format(string2, new object[]
				{
					text,
					xsyncDoodadInfo.owner.Name,
					xsyncDoodadInfo.maxroll,
					xsyncDoodadInfo.playerroll
				});
				XSingleton<UiUtility>.singleton.EditSystemNoticeTip(text3, num);
			}
			if (xsyncDoodadInfo.doo.type == XDoodadType.Item)
			{
				XHUDDoodadArgs @event = XEventPool<XHUDDoodadArgs>.GetEvent();
				@event.itemid = (int)xsyncDoodadInfo.doo.id;
				@event.count = (int)xsyncDoodadInfo.doo.count;
				@event.Firer = xsyncDoodadInfo.owner;
				XSingleton<XEventMgr>.singleton.FireEvent(@event);
			}
		}

		// Token: 0x0600BD78 RID: 48504 RVA: 0x002759DC File Offset: 0x00273BDC
		public void Update()
		{
			XPlayer player = XSingleton<XEntityMgr>.singleton.Player;
			if (XEntity.ValideEntity(player))
			{
				for (int i = 0; i < this._doodads.Count; i++)
				{
					if (this._doodads[i].doodad != null)
					{
						if (this._doodads[i].billboard != null)
						{
							Vector3 position = new Vector3(this._doodads[i].doodad.transform.position.x, this._doodads[i].doodad.transform.position.y + 0.2f, this._doodads[i].doodad.transform.position.z);
							this._doodads[i].billboard.transform.position = position;
							this._doodads[i].billboard.transform.rotation = XSingleton<XScene>.singleton.GameCamera.Rotaton;
						}
						if (player != null && this._doodads[i].dropped && !this._doodads[i].picked)
						{
							float num = Vector3.Magnitude(player.EngineObject.Position - this._doodads[i].doodad.transform.position);
							if (num < 1f)
							{
								this.OnDoodadPicked(this._doodads[i].wave, this._doodads[i].index);
							}
						}
					}
				}
			}
		}

		// Token: 0x0600BD79 RID: 48505 RVA: 0x00275BC4 File Offset: 0x00273DC4
		public void ReceiveDoodadServerInfo(EnemyDoodadInfo info)
		{
			XEntityStatistics.RowData byID = XSingleton<XEntityMgr>.singleton.EntityStatistics.GetByID(info.dropperTemplateID);
			if (byID != null)
			{
				if (byID.Type == 1)
				{
					XSingleton<XTimerMgr>.singleton.SetTimer(0.05f, new XTimerMgr.ElapsedEventHandler(this.GenerateDoodadFromServer), info);
				}
				else
				{
					this.GenerateDoodadFromServer(info);
				}
			}
			else
			{
				this.GenerateDoodadFromServer(info);
			}
		}

		// Token: 0x0600BD7A RID: 48506 RVA: 0x00275C30 File Offset: 0x00273E30
		public void GenerateDoodadFromServer(object obj)
		{
			EnemyDoodadInfo enemyDoodadInfo = (EnemyDoodadInfo)obj;
			XLevelDoodad xlevelDoodad = new XLevelDoodad();
			xlevelDoodad.wave = enemyDoodadInfo.waveid;
			Vector3 pos = new Vector3(enemyDoodadInfo.pos.x, enemyDoodadInfo.pos.y, enemyDoodadInfo.pos.z);
			xlevelDoodad.pos = pos;
			xlevelDoodad.type = (XDoodadType)enemyDoodadInfo.type;
			xlevelDoodad.id = enemyDoodadInfo.id;
			xlevelDoodad.count = enemyDoodadInfo.count;
			xlevelDoodad.dropped = true;
			xlevelDoodad.picked = false;
			xlevelDoodad.lastPickTime = 0f;
			xlevelDoodad.index = enemyDoodadInfo.index;
			xlevelDoodad.token = 0U;
			xlevelDoodad.templateid = enemyDoodadInfo.dropperTemplateID;
			xlevelDoodad.roleid = enemyDoodadInfo.roleid;
			this._doodads.Add(xlevelDoodad);
			this.GenerateDoodad(xlevelDoodad, pos);
		}

		// Token: 0x0600BD7B RID: 48507 RVA: 0x00275D04 File Offset: 0x00273F04
		public void ExternalGenerateDoodad(int doodadid, int type, int waveid, Vector3 pos, uint templateid, uint index, uint count)
		{
			XLevelDoodad xlevelDoodad = new XLevelDoodad();
			xlevelDoodad.wave = waveid;
			xlevelDoodad.pos = pos;
			xlevelDoodad.type = (XDoodadType)type;
			xlevelDoodad.id = (uint)doodadid;
			xlevelDoodad.count = count;
			xlevelDoodad.dropped = true;
			xlevelDoodad.picked = false;
			xlevelDoodad.lastPickTime = 0f;
			xlevelDoodad.index = index;
			xlevelDoodad.token = 0U;
			xlevelDoodad.templateid = templateid;
			this._doodads.Add(xlevelDoodad);
			this.GenerateDoodad(xlevelDoodad, pos);
		}

		// Token: 0x0600BD7C RID: 48508 RVA: 0x00275D84 File Offset: 0x00273F84
		public void DelayGenerateDoodad(object obj)
		{
			bool isCurrentLevelFinished = XSingleton<XLevelFinishMgr>.singleton.IsCurrentLevelFinished;
			if (!isCurrentLevelFinished)
			{
				XLevelDoodad xlevelDoodad = (XLevelDoodad)obj;
				if (xlevelDoodad.token > 0U)
				{
					this._TimerToken.Contains(xlevelDoodad.token);
					this._TimerToken.Remove(xlevelDoodad.token);
				}
				this.GenerateDoodadObject(xlevelDoodad, xlevelDoodad.pos);
			}
		}

		// Token: 0x0600BD7D RID: 48509 RVA: 0x00275DEC File Offset: 0x00273FEC
		public List<GameObject> GetDoodadsInScene(XDoodadType type)
		{
			this._DropedDoodads.Clear();
			for (int i = 0; i < this._doodads.Count; i++)
			{
				if (this._doodads[i].type == type && this._doodads[i].dropped && !this._doodads[i].picked)
				{
					this._DropedDoodads.Add(this._doodads[i].doodad);
				}
			}
			return this._DropedDoodads;
		}

		// Token: 0x0600BD7E RID: 48510 RVA: 0x00275E90 File Offset: 0x00274090
		public void PickAllDoodad()
		{
			for (int i = 0; i < this._doodads.Count; i++)
			{
				if (this._doodads[i].dropped && !this._doodads[i].picked)
				{
					this.OnDoodadPicked(this._doodads[i].wave, this._doodads[i].index);
				}
			}
		}

		// Token: 0x0600BD7F RID: 48511 RVA: 0x00275F13 File Offset: 0x00274113
		public void OnReconnect()
		{
			this.OnClearDoodad();
		}

		// Token: 0x04004D2B RID: 19755
		private List<XLevelDoodad> _doodads = new List<XLevelDoodad>();

		// Token: 0x04004D2C RID: 19756
		private GameObject _HpbarRoot = null;

		// Token: 0x04004D2D RID: 19757
		private List<GameObject> _DropedDoodads = new List<GameObject>();

		// Token: 0x04004D2E RID: 19758
		private List<uint> _TimerToken = new List<uint>();

		// Token: 0x04004D2F RID: 19759
		private Dictionary<uint, XSyncDoodadInfo> _NoticeDictionary = new Dictionary<uint, XSyncDoodadInfo>();

		// Token: 0x04004D30 RID: 19760
		private XTimerMgr.ElapsedEventHandler _showRollOverNoticeCb = null;

		// Token: 0x04004D31 RID: 19761
		private XTimerMgr.ElapsedEventHandler _delayGenerateDoodadCb = null;

		// Token: 0x04004D32 RID: 19762
		private float _DoodadPickCD = 0f;
	}
}
